package cdu.sl.aichatdemo.config;

import cdu.sl.aichatdemo.mapper.CustomChatMemoryMapper;
import cdu.sl.aichatdemo.service.TitleGenerateService;
import cdu.sl.aichatdemo.service.impl.CustomChatMemoryImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.chat.memory.ChatMemory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Description 聊天记忆配置类
 * @Author sunlin5@asiainfo.com
 * @Date 2025/8/28
 * @Version 1.0
 */
@Slf4j
@Configuration
@RequiredArgsConstructor
public class ChatMemoryConfig {

    private final TitleGenerateService titleGenerateService;

    private final CustomChatMemoryMapper customChatMemoryMapper;

    @Bean
    public ChatMemory chatMemory() {
        log.info("配置自定义ChatMemory实现");
        return new CustomChatMemoryImpl(customChatMemoryMapper, titleGenerateService);
    }

}
